<?php
/**
 * Copyright (c) 2006, PORTALIER Julien
 *
 * Licensed under The LGPL License
 * Redistributions of files must retain the above copyright notice.
 *
 * @package      Feather's website
 * @copyright    Copyright (c) 2006, Julien PORTALIER
 * @link         http://feather.portalier.com
 * @license      http://www.opensource.org/licenses/lgpl-license.php The LGPL License
 */

class GroupsController extends Controller
{
	function add()
	{
		$this->Group->id = null;
		
		if (!$this->acl->inGroup(Config::admins))
			$this->acl->permissionDenied();
		
		if ($this->Group->save())
			$mesg = s_('Member has been added to group %s.', $this->acl->groupTable[$this->data['Group']['name']]);
		else
			$mesg = _('Oops, an error occured.');
		
		$this->flasg($mesg, '/members?q='.urlencode($this->data['Group']['member_id']));
	}
	
	function remove($member_id, $name)
	{
		$this->Group->conditions(array(
			'member_id' => $member_id,
			'name' => $name
		));
		$this->Group->id = $this->Group->field('id', null, -1);
		
		if ($this->Group->id and $this->Group->delete())
			$mesg = s_('Member has been removed from group %s.', $this->acl->groupTable[$name]);
		else
			$mesg = _('Oops, an error occured.');
		
		$this->flash($mesg, '/members?q='.urlencode($member_id));
	}
}
?>